# -*- coding: utf-8 -*-
# @Time : 2021/3/15 15:47
# @Author : 张宇鹏
# @FileName: a1.py


class Employee:
    """所有员工的基类"""
    empCount = 0

    def __init__(self, name, salary):
        self.name = name
        self.salary = salary
        Employee.empCount += 1

    def displayCount(self):
        print("Total Employee %d" % Employee.empCount)

    def displayEmployee(self):
        print("Name : ", self.name, ", Salary: ", self.salary)



class Point:
    def __init__(self, x=0, y=0):
        self.x = x
        self.y = y

    def __del__(self):
        class_name = self.__class__.__name__
        print(class_name, "销毁")


class Parent:  # 定义父类
    parentAttr = 100

    def __init__(self):
        print("调用父类构造函数")

    def parentMethod(self):
        print('调用父类方法')

    def setAttr(self, attr):
        Parent.parentAttr = attr

    def getAttr(self):
        print("父类属性 :", Parent.parentAttr)


class Child(Parent):  # 定义子类
    def __init__(self):
        print("调用子类构造方法")

    def childMethod(self):
        print('调用子类方法')


if __name__ == '__main__':

    # print("aaaa")
    # "创建 Employee 类的第一个对象"
    # emp1 = Employee("Zara", 2000)
    # "创建 Employee 类的第二个对象"
    # emp2 = Employee("Manni", 5000)
    # emp1.displayEmployee()
    # emp2.displayEmployee()
    # print("Total Employee %d" % Employee.empCount)

    # pt1 = Point()
    # pt2 = pt1
    # pt3 = pt1
    # print(id(pt1), id(pt2), id(pt3))  # 打印对象的id
    # del pt1
    # del pt2
    # # del pt3

    c = Child()  # 实例化子类
    c.childMethod()  # 调用子类的方法
    c.parentMethod()  # 调用父类方法
    c.setAttr(200)  # 再次调用父类的方法 - 设置属性值
    c.getAttr()  # 再次调用父类的方法 - 获取属性值


